<template>
  <div>
    <ul>
      <li v-for="(val, index) in arr" :key="index">{{ val }}</li>
    </ul>

    <!-- 翻转数组 -->
    <button @click="fn">翻转</button>

    <!-- 数组截取 -->
    <button @click="fnslice">截取前三个</button>

    <!-- 更换数组第一个值 -->
    <button @click="fnand">更新</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [9, 1, 2, 6, 0],
    };
  },
  methods:{
    fn() {
      this.arr.reverse()
    },
    fnslice() {
      // let re = this.arr.slice(0,3)

      // 解决更新数组办法
      this.arr = this.arr.slice(0,3)
      // console.log(re);
    },
    fnand() {
      // let ra = this.arr[0] = 1000

      // 解决办法
      this.$set(this.arr,0,1000)
      // console.log(ra);
    }
  }
};
</script>

<style>
</style>